package a.f.h.d;

import a.c.a;
import a.c.e;
import a.c.n;

import java.util.ArrayList;

public class m
  implements q
{
  protected d[] a;
  private a.c.q b;
  private int[] c;
  private int[] d;
  private int[] e;
  private int[] f;
  private int[] g;
  private int h;
  private int i;
  private w j;
  private ArrayList k;
  private a.c.d[] l;
  private a.c.d[] m;
  private int[] n;
  Object[] o;
  int p;
  e q;
  e r;
  n s;
  p[] t;
  public static boolean u;
  
  public int a(a.c.q paramq, e parame1, e parame2, n paramn1, n paramn2, int paramInt, ArrayList paramArrayList1, ArrayList paramArrayList2, n paramn3, n paramn4)
  {
    try
    {
      return b(paramq, parame1, parame2, paramn1, paramn2, paramInt, paramArrayList1, paramArrayList2, paramn3, paramn4);
    }
    catch (a_ locala_)
    {
      z localz = new z();
      return localz.a(paramq, parame1, parame2, paramn1, paramn2, paramInt, paramArrayList1, paramArrayList2, paramn3, paramn4);
    }
  }
  
  protected int b(a.c.q paramq, e parame1, e parame2, n paramn1, n paramn2, int paramInt, ArrayList paramArrayList1, ArrayList paramArrayList2, n paramn3, n paramn4)
    throws m.a_
  {
    int i12 = j.r;
    boolean bool = j.q;
    this.p = paramInt;
    this.q = parame1;
    this.r = parame2;
    this.h = paramq.m();
    this.i = paramq.k();
    this.b = paramq;
    this.c = new int[this.h];
    this.d = new int[this.h];
    this.e = new int[this.i];
    this.f = new int[this.i];
    this.g = new int[this.h];
    this.o = new Object[this.i];
    this.n = new int[this.h];
    this.l = new a.c.d[this.h];
    this.m = new a.c.d[this.h];
    this.s = paramn1;
    this.a = new d[this.h];
    this.k = new ArrayList(paramq.k());
    this.j = new w(this.i);
    int i1 = 0;
    if (i1 < paramArrayList1.size()) {}
    Object localObject2;
    label311:
    while (i12 != 0)
    {
      localObject2 = (d)paramArrayList1.get(i1);
      if (bool) {
        break label336;
      }
      a.c.m localm1 = ((d)localObject2).b();
      do
      {
        do
        {
          if (!localm1.e()) {
            break label311;
          }
          a.c.d locald1 = localm1.a();
          int i4 = locald1.d();
          this.a[locald1.d()] = localObject2;
          this.c[i4] = ((d)localObject2).a();
          if (bool) {
            break;
          }
          if (this.c[i4] < 0) {
            throw new a("found negative capacity");
          }
          localm1.f();
        } while (!bool);
        i1++;
      } while (i12 != 0);
      if (!bool) {
        break;
      }
    }
    label336:
    Object localObject1 = this.b.w();
    do
    {
      if (!((a.c.m)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.m)localObject1).a();
      this.l[localObject2.d()] = ((a.c.d)paramn4.get(localObject2));
      this.m[localObject2.d()] = ((a.c.d)paramn3.get(localObject2));
      ((a.c.m)localObject1).f();
      if ((i12 == 0) && (bool)) {
        break label439;
      }
    } while (!bool);
    if (i12 == 0)
    {
      this.t = new p[this.i];
      label439:
      localObject1 = paramq.v();
      do
      {
        if (!((a.c.w)localObject1).e()) {
          break;
        }
        localObject2 = ((a.c.w)localObject1).d();
        if (i12 == 0)
        {
          if (bool) {
            break label511;
          }
          this.t[localObject2.f()] = new p((e)localObject2, ((e)localObject2).f());
          ((a.c.w)localObject1).f();
        }
      } while (!bool);
    }
    label511:
    Object localObject3 = a();
    localObject1 = localObject3;
    int i2 = 0;
    int i3 = 0;
    label526:
    if (i3 < paramArrayList2.size()) {}
    label758:
    label759:
    do
    {
      ArrayList localArrayList = (ArrayList)paramArrayList2.get(i3);
      int i6 = 0;
      int i7 = 0;
      int i8 = 0;
      if (!bool)
      {
        int i9 = 0;
        d locald;
        do
        {
          do
          {
            if (i9 >= localArrayList.size()) {
              break label963;
            }
            locald = (d)localArrayList.get(i9);
            if (bool) {
              break;
            }
            if (this.g[locald.b[0].d()] == 1)
            {
              if (i12 != 0) {
                continue;
              }
              if (this.g[locald.b[1].d()] == 1)
              {
                i2++;
                a.c.d locald3 = this.m[locald.b[0].d()];
                int i10 = 0;
                do
                {
                  do
                  {
                    if (this.g[locald3.d()] != 1) {
                      break;
                    }
                    i10 += paramn1.getInt(this.a[locald3.d()].b(locald3));
                    locald3 = this.m[locald3.d()];
                    if (i12 != 0) {
                      break label759;
                    }
                    if (bool) {
                      break label758;
                    }
                  } while (!bool);
                } while (i12 != 0);
                i10 += paramn1.getInt(this.a[locald3.d()].b(locald3));
                int i11 = 0;
                locald3 = this.m[locald.b[1].d()];
                do
                {
                  do
                  {
                    if (this.g[locald3.d()] != 1) {
                      break;
                    }
                    i11 += paramn1.getInt(this.a[locald3.d()].b(locald3));
                    locald3 = this.m[locald3.d()];
                    if (i12 != 0) {
                      break label880;
                    }
                    if (bool) {
                      break label878;
                    }
                  } while (!bool);
                } while (i12 != 0);
                i11 += paramn1.getInt(this.a[locald3.d()].b(locald3));
                if (i12 == 0)
                {
                  if (i11 <= 400)
                  {
                    if (i12 != 0) {
                      break label952;
                    }
                    if (i10 <= 400) {
                      break label941;
                    }
                  }
                  if (i12 != 0) {}
                }
                else
                {
                  if (i11 >= i10) {
                    break label932;
                  }
                  c(locald);
                }
                if (i12 == 0) {
                  if (bool) {
                    e(locald);
                  }
                }
                i6 = 1;
                i8 += i11;
                i7 += i10;
              }
            }
            i9++;
          } while (!bool);
        } while (i12 != 0);
        if (i12 == 0)
        {
          if (i6 == 0) {
            i9 = 0;
          }
          do
          {
            do
            {
              if (i9 >= localArrayList.size()) {
                break label1093;
              }
              locald = (d)localArrayList.get(i9);
              if (bool) {
                break;
              }
              if (this.g[locald.b[0].d()] == 1)
              {
                if (i12 != 0) {
                  continue;
                }
                if (this.g[locald.b[1].d()] == 1)
                {
                  if (i12 == 0)
                  {
                    if (i8 < i7) {
                      c(locald);
                    }
                  }
                  else
                  {
                    if (i12 != 0) {
                      continue;
                    }
                    if (!bool) {
                      break label1085;
                    }
                  }
                  e(locald);
                }
              }
              i9++;
            } while (!bool);
            i3++;
          } while (i12 != 0);
        }
        if (!bool) {
          break label526;
        }
      }
      if ((i12 != 0) || (i2 > 0)) {
        break;
      }
    } while ((i12 != 0) || (bool));
    label878:
    label880:
    a.c.m localm2 = this.b.w();
    label932:
    label941:
    label952:
    label963:
    label1093:
    do
    {
      if (!localm2.e()) {
        break;
      }
      a.c.d locald2 = localm2.a();
      if (bool) {
        break label1196;
      }
      int i5 = locald2.d();
      paramn2.a(locald2, this.g[i5]);
      localm2.f();
    } while (!bool);
    label1085:
    return localObject1;
  }
  
  protected void a(d paramd)
  {
    int i1 = j.r;
    boolean bool = j.q;
    a.c.d locald = paramd.b[0];
    if (this.g[locald.d()] == 1) {
      this.c[this.a[locald.d()].b(locald).d()] = 0;
    }
    while (i1 != 0)
    {
      locald = this.m[locald.d()];
      if (i1 != 0) {
        break label103;
      }
      if (bool) {
        break label94;
      }
      if (!bool) {
        break;
      }
    }
    label94:
    label103:
    do
    {
      for (locald = this.m[paramd.b[1].d()]; !bool; locald = this.m[locald.d()])
      {
        if (this.g[locald.d()] != 1) {
          break;
        }
        this.c[this.a[locald.d()].b(locald).d()] = 0;
      }
    } while (i1 != 0);
  }
  
  protected void c(d paramd)
  {
    int i1 = j.r;
    boolean bool = j.q;
    a.c.d locald = paramd.b[0];
    if (this.g[locald.d()] == 1) {
      this.c[this.a[locald.d()].b(locald).d()] = 0;
    }
    while (i1 != 0)
    {
      locald = this.m[locald.d()];
      if (i1 != 0) {
        break label115;
      }
      if (bool) {
        break label94;
      }
      if (!bool) {
        break;
      }
    }
    label94:
    label115:
    do
    {
      for (locald = this.l[paramd.b[0].d()]; !bool; locald = this.l[locald.d()])
      {
        if (this.g[this.a[locald.d()].b(locald).d()] != 1) {
          break;
        }
        this.c[this.a[locald.d()].b(locald).d()] = 0;
      }
    } while (i1 != 0);
  }
  
  protected void e(d paramd)
  {
    int i1 = j.r;
    boolean bool = j.q;
    a.c.d locald = paramd.b[1];
    if (this.g[locald.d()] == 1) {
      this.c[this.a[locald.d()].b(locald).d()] = 0;
    }
    while (i1 != 0)
    {
      locald = this.m[locald.d()];
      if (i1 != 0) {
        break label115;
      }
      if (bool) {
        break label94;
      }
      if (!bool) {
        break;
      }
    }
    label94:
    label115:
    do
    {
      for (locald = this.l[paramd.b[1].d()]; !bool; locald = this.l[locald.d()])
      {
        if (this.g[this.a[locald.d()].b(locald).d()] != 1) {
          break;
        }
        this.c[this.a[locald.d()].b(locald).d()] = 0;
      }
    } while (i1 != 0);
  }
  
  protected int a()
    throws m.a_
  {
    int i5 = j.r;
    boolean bool = j.q;
    a.c.d locald1 = this.p;
    a.c.m localm1 = this.b.w();
    a.c.d locald3;
    do
    {
      if (!localm1.e()) {
        break;
      }
      locald3 = localm1.a();
      if (bool) {
        break label101;
      }
      int i2 = locald3.d();
      this.d[i2] = this.s.getInt(locald3);
      this.n[i2] = this.c[i2];
      this.g[i2] = 0;
      localm1.f();
    } while (!bool);
    label101:
    a.c.d locald2 = 0;
    label136:
    Object localObject1;
    label340:
    int i3;
    label429:
    label460:
    label469:
    do
    {
      do
      {
        if (locald2 < this.i) {
          break label136;
        }
        while (i5 != 0)
        {
          this.f[locald2] = 0;
          locald2++;
          if ((i5 == 0) && (bool)) {
            break label484;
          }
          if (!bool) {
            break;
          }
        }
        if (locald1 < 1) {
          break;
        }
        a(this.q, this.r, this.d, this.n, this.g, this.o);
        locald3 = locald1;
        if (bool) {
          break label485;
        }
        localObject1 = this.r;
        a.c.d locald4;
        int i4;
        int i1;
        do
        {
          do
          {
            if (localObject1 == this.q) {
              break;
            }
            Object localObject2 = this.o[localObject1.f()];
            if ((i5 != 0) || ((localObject2 instanceof a.c.d)))
            {
              locald4 = (a.c.d)localObject2;
              i4 = locald4.d();
              if (i5 == 0)
              {
                if (localObject1 == locald4.f())
                {
                  locald2 = this.n[i4];
                  localObject1 = locald4.e();
                  if (i5 != 0) {
                    continue;
                  }
                  if (!bool) {}
                }
                else
                {
                  locald2 = this.g[i4];
                }
              }
              else
              {
                localObject1 = locald4.f();
                if (i5 != 0) {
                  continue;
                }
                if (!bool) {}
              }
            }
            else
            {
              throw new a_();
            }
          } while (locald2 >= locald3);
          i1 = locald2;
          if (i5 != 0) {
            break label469;
          }
          if ((i5 == 0) && (bool)) {
            break label340;
          }
        } while (!bool);
        localObject1 = this.r;
        if (localObject1 != this.q) {}
        while (i5 != 0)
        {
          do
          {
            do
            {
              i3 = ((e)localObject1).f();
              locald4 = (a.c.d)this.o[i3];
              i4 = locald4.d();
              if (bool) {
                break;
              }
              if (localObject1 != locald4.f()) {
                break label429;
              }
              this.g[i4] += i1;
              this.n[i4] -= i1;
              localObject1 = locald4.e();
              if (i5 != 0) {
                break label460;
              }
            } while (!bool);
            this.g[i4] -= i1;
            this.n[i4] += i1;
            localObject1 = locald4.f();
          } while (!bool);
          locald1 -= i1;
        }
      } while (!bool);
    } while (i5 != 0);
    locald2 = 0;
    label484:
    label485:
    a.c.m localm2 = this.b.w();
    do
    {
      if (!localm2.e()) {
        break;
      }
      localObject1 = localm2.a();
      i3 = ((a.c.d)localObject1).d();
      if (i5 == 0)
      {
        if (bool) {
          break label556;
        }
        locald2 += this.g[i3] * this.d[i3];
        localm2.f();
      }
    } while (!bool);
    label556:
    return locald2;
  }
  
  private void a(e parame1, e parame2, int[] paramArrayOfInt1, int[] paramArrayOfInt2, int[] paramArrayOfInt3, Object[] paramArrayOfObject)
  {
    int i8 = j.r;
    boolean bool = j.q;
    this.j.a();
    int i1 = 0;
    if (i1 < this.i)
    {
      if (i8 != 0) {}
    }
    else
    {
      do
      {
        this.e[i1] = 2147483647;
        paramArrayOfObject[i1] = null;
        i1++;
        if (bool) {
          break label84;
        }
        if (!bool) {
          break;
        }
        this.k.clear();
      } while (i8 != 0);
      this.e[parame1.f()] = 0;
    }
    label84:
    this.j.a(0, this.t[parame1.f()]);
    label182:
    int i3;
    label329:
    label338:
    label357:
    do
    {
      if (!this.j.c())
      {
        p localp = this.j.b();
        this.j.a(localp);
        e locale1 = localp.b;
        int i2 = localp.c;
        if (i8 == 0)
        {
          this.k.add(locale1);
          if (parame2 == locale1) {}
        }
        else
        {
          int i4;
          e locale2;
          int i5;
          do
          {
            i7 = this.e[i2] + this.f[i2];
            locald = locale1.h();
            do
            {
              do
              {
                if (locald == null) {
                  break label357;
                }
                i4 = locald.d();
                if (i8 != 0) {
                  break label182;
                }
                if (bool) {
                  break;
                }
                if (paramArrayOfInt2[i4] >= 1)
                {
                  locale2 = locald.f();
                  i3 = locale2.f();
                  i5 = i7 - this.f[i3] + paramArrayOfInt1[i4];
                  if (i8 != 0) {
                    continue;
                  }
                  if (i5 < this.e[i3])
                  {
                    if (i8 == 0) {
                      if (this.e[i3] == 2147483647)
                      {
                        this.j.a(i5, this.t[i3]);
                        if (i8 != 0) {
                          break label338;
                        }
                        if (!bool) {
                          break label329;
                        }
                      }
                    }
                    this.j.a(this.t[i3], i5);
                    this.e[i3] = i5;
                    paramArrayOfObject[i3] = locald;
                  }
                }
                locald = locald.i();
              } while (!bool);
            } while (i8 != 0);
            locald = locale1.i();
            if (locald == null) {
              break;
            }
            i4 = locald.d();
            if ((i8 != 0) || ((i8 == 0) && (bool))) {
              break label559;
            }
          } while (bool);
          if (paramArrayOfInt3[i4] >= 1)
          {
            locale2 = locald.e();
            i3 = locale2.f();
            i5 = i7 - this.f[i3] - paramArrayOfInt1[i4];
            if (i8 != 0) {
              break label542;
            }
            if (i5 < this.e[i3])
            {
              if (i8 == 0) {
                if (this.e[i3] == 2147483647)
                {
                  this.j.a(i5, this.t[i3]);
                  if (i8 != 0) {
                    break label526;
                  }
                  if (!bool) {
                    break label517;
                  }
                }
              }
              this.j.a(this.t[i3], i5);
              this.e[i3] = i5;
              paramArrayOfObject[i3] = locald;
            }
          }
          a.c.d locald = locald.j();
          if (!bool) {
            break;
          }
        }
      }
    } while (i8 != 0);
    label517:
    label526:
    label542:
    label559:
    int i6 = this.e[parame2.f()];
    if (i8 == 0) {
      if (i6 == 0) {
        return;
      }
    }
    int i7 = 0;
    do
    {
      if (i7 >= this.k.size()) {
        break;
      }
      i3 = ((e)this.k.get(i7)).f();
      this.f[i3] += this.e[i3] - i6;
      i7++;
    } while (!bool);
  }
  
  static class a_
    extends Exception
  {
    a_()
    {
      super();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.h.d.m

 * JD-Core Version:    0.7.0.1

 */